package com.codeduck.mp.config;

import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.codeduck.mp.utils.SnowflakeIdGenUtil;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author: <a href="mailto:codeduck@163.com">Codeduck</a>
 * @createDate: 2021-12-30
 */
@Configuration
public class SnowflakeIdConfig implements IdentifierGenerator {

    @Resource
    private SnowflakeIdGenUtil snowflakeIdGenUtil;

    @Override
    public Number nextId(Object entity) {
        return snowflakeIdGenUtil.nextId();
    }
}
